//加载路由配置
import type { RouteRecordRaw } from 'vue-router';

import DefaultIndex from '@/layout/default/index.vue'


const loginUrl = import.meta.env.VITE_APP_LOGIN_PATH || '/login';

//动态路由，由state加载登陆后
const dynamicRoutes: RouteRecordRaw[] = [

];

//所有菜单
const defaultRoutes: RouteRecordRaw[] = [
  {
    path: '/default-idoo',
    name: 'default-idoo',
    component: DefaultIndex,
    children: [
      {
        path: '/employess-staff',
        name: 'employess-staff',
        component: () => import('@/views/employess/staff/worker/index.vue'),
        props: true,
        meta: { title: '员工', KeepAlive: true},
      },
      {
        path: '/employess-staff/add',
        name: 'employess-staff-add',
        component: () => import('@/views/employess/staff/worker/details/index.vue'),
        props: true,
        meta: { title: '新增员工', KeepAlive: true},
      },

      {
        path: '/employess/organizational',
        name: 'employess-organizational',
        props: true,
        component: function () {
          return import('@/views/employess/staff/organizational/index.vue')
        },
        meta: { title: '组织结构', KeepAlive: true },
      },
      {
        path: '/employess-department',
        name: 'employess-department',
        props: true,
        component: () => import('@/views/employess/department/index.vue'),
        meta: { title: '部门', KeepAlive: true },
      },
      {
        path: '/employess/report/skill',
        name: 'employess-skill',
        props: true,
        component: () => import('@/views/employess/report/skill/index.vue'),
        meta: { title: '技能', KeepAlive: true },
      }, {
        path: '/employess/report/authentication',
        name: 'employess-authentication',
        props: true,
        component: () => import('@/views/employess/report/authentication/index.vue'),
        meta: { title: '认证', KeepAlive: true },
      },
      {
        path: '/document-docmanage',
        name: 'document-docmanage',
        component: () => import('@/views/document/manage/index.vue'),
        props: true,
        meta: { title: '文档', KeepAlive: true},
      },
      {
        path: '/setting-roles',
        name: 'setting-roles',
        component: () => import('@/views/system/role/index.vue'),
        props: true,
        meta: { title: '角色', KeepAlive: true},
      },
      {
        path: '/setting-roles/add',
        name: 'setting-roles-add',
        component: () => import('@/views/system/role/details/index.vue'),
        props: true,
        meta: { title: '新增角色', KeepAlive: true},
      },
      {
        path: '/setting-menus',
        name: 'setting-menus',
        component: () => import('@/views/system/menu/index.vue'),
        props: true,
        meta: { title: '菜单', KeepAlive: true},
      },
      {
        path: '/setting-menus/add',
        name: 'setting-menus-add',
        component: () => import('@/views/system/menu//details/index.vue'),
        props: true,
        meta: { title: '新增菜单', KeepAlive: true},
      },
      {
        path: '/setting-company',
        name: 'setting-company',
        component: () => import('@/views/system/company/index.vue'),
        props: true,
        meta: { title: '公司', KeepAlive: true},
      },
      {
        path: '/setting-system-config',
        name: 'setting-system-config',
        component: () => import('@/views/system/config/index.vue'),
        props: true,
        meta: { title: '一般设置', KeepAlive: true},
      },
      {
        path: '/setting-system-config/add',
        name: 'setting-system-config-add',
        component: () => import('@/views/system/config/details/index.vue'),
        props: true,
        meta: { title: '新增参数', KeepAlive: true},
      },
      {
        path: '/setting-user',
        name: 'setting-user',
        component: () => import('@/views/system/user/index.vue'),
        props: true,
        meta: { title: '用户', KeepAlive: true},
      },
      {
        path: '/setting-user/add',
        name: 'setting-user-add',
        component: () => import('@/views/system/user/details/index.vue'),
        props: true,
        meta: { title: '新增用户', KeepAlive: true},
      },
      {
        path: '/customer-list',
        name: 'customer-list',
        component: () => import('@/views/customer/list/index.vue'),
        props: true,
        meta: { title: '客户列表', KeepAlive: true},
      },
      {
        path: '/customer-list/add',
        name: 'customer-list-add',
        component: () => import('@/views/customer/list/details/index.vue'),
        props: true,
        meta: { title: '新增客户', KeepAlive: true},
      }
    ]
  },
];

//主菜单 ; 登录界面路由
const coreRoutes: RouteRecordRaw[] = [
  {
    path: '/main-interface',
    name: 'mainInterface',
    meta: {
      title: '主界面',
      KeepAlive: false,
    },
    component: () => import('@/views/mainInterface/index.vue')
  },
  {
    path: loginUrl,
    name: 'login',
    component: () => import('@/views/login/index.vue')
  },

  //这个后期需要修改 。。。。。。先这么写着
  {
    path: '/:catchAll(.*)', // 使用参数 catchAll 并搭配正则表达式 (.*) 来匹配任意路径
    redirect: loginUrl
  }
];

//导出路由集合
const routes: RouteRecordRaw[] = [
  ...coreRoutes,
  ...defaultRoutes,
  ...dynamicRoutes
];
export { routes };
